/*
 * @Author: 缄默
 * @Date: 2021-12-12 14:57:54
 * @LastEditors: 缄默
 * @LastEditTime: 2021-12-14 19:54:36
 */

//装饰者模式

#include <iostream>

using namespace std;

class Component {
public:
    virtual void Operation() = 0;
    virtual ~Component() { }
};

class ConcreteComponent : public Component {
public:
    void Operation() {
        cout << "ConcreteComponent::Operation..." << endl;
    }
};


class Decorator : public Component {
private:
    Component* _component;

public:
    Decorator(Component* com) {
        _component = com;
    }

    void Operation() {
        cout << "Decorator::Operation..." << endl;
        _component->Operation();
    }

};


int main() {
    Component* com = new ConcreteComponent();
    Component* dec = new Decorator(com);
    Component* dec2 = new Decorator(dec);
    dec2->Operation();

    delete com;
    delete dec;
    delete dec2;


    return 0;
}
